package leecode

func countNumbersWithUniqueDigits(n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return 10
	}
	result, temp := 10, 9
	// f(1) = 10
	// f(k) = 9 * .....*(9-k+2)
	// f(2) = 9 * 9
	// f(3) = 9 * 9 * 8
	// f(4) = 9 * 9 * 8 * 7
	for i := 0; i < n-1; i++ {
		temp *= 9 - i
		result += temp
	}
	return result
}
